package cn.com.guage.monitor.log.hikair.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Controller;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;

import cn.com.guage.monitor.log.kafka.log.KafkaProducer;

@Controller
public class KafkaTestController {

	@Autowired
	private KafkaProducer producer;
	
	@RequestMapping("/testSendMsg")
	@ResponseBody
	public String testSendMsg(){
		producer.send();
		return "success";
	}
	
	
	
	@RequestMapping("/testSendFrameworkNoJson")
	@ResponseBody
	public String testSendFrameworkNoJson(){
		ListenableFuture<SendResult<String, String>> result = producer.sendFrameworkNoJson();
		return  JSON.toJSONString(result);
	}
	
	@RequestMapping("/testSendAppNoJson")
	@ResponseBody
	public String testSendAppNoJson(){
		ListenableFuture<SendResult<String, String>> result = producer.sendAppNoJson();
		return  JSON.toJSONString(result);
	}
	
	@RequestMapping("/testSendJvm")
	@ResponseBody
	public String testSendJvm(){
		ListenableFuture<SendResult<String, String>> result = producer.sendJvm();
		return  JSON.toJSONString(result);
	}
	
	@RequestMapping("/testSendJvm2")
	@ResponseBody
	public String testSendJvm2(){
		ListenableFuture<SendResult<String, String>> result = producer.sendJvm2();
		return  JSON.toJSONString(result);
	}
	@RequestMapping("/testSendSql")
	@ResponseBody
	public String testSendSql(){
		ListenableFuture<SendResult<String, String>> result = producer.sendSql();
		return  JSON.toJSONString(result);
	}
	@RequestMapping("/testSendApi")
	@ResponseBody
	public String testSendApi(){
		ListenableFuture<SendResult<String, String>> result = producer.sendApi();
		return  JSON.toJSONString(result);
	}
	
	@RequestMapping("/testSendTrace")
	@ResponseBody
	public String testSendTrace(){
		ListenableFuture<SendResult<String, String>> result = producer.sendTrace();
		return  JSON.toJSONString(result);
	}
	
	@RequestMapping("/sendTracePartitionAndKey")
	@ResponseBody
	public String sendTracePartitionAndKey(){
		String result = producer.sendTracePartitionAndKey();
		return  result;
	}
	
	@RequestMapping("/testSendEnv")
	@ResponseBody
	public String testSendEnv(){
		ListenableFuture<SendResult<String, String>> result = producer.sendEnv();
		return  JSON.toJSONString(result);
	}
	@RequestMapping("/testSendDbpool")
	@ResponseBody
	public String testSendDbpool(){
		ListenableFuture<SendResult<String, String>> result = producer.sendDbPool();
		return  JSON.toJSONString(result);
	}
}
